A paper equilateral triangle $ABC$ has side length 12. The paper triangle is folded so that vertex $A$ touches a point on side $\overline{BC}$ a distance 9 from point $B$. Find the square of the length of the line segment along which the triangle is folded.

[asy]
import cse5;
size(12cm);
pen tpen = defaultpen + 1.337;
real a = 39/5.0;
real b = 39/7.0;
pair B = MP("B", (0,0), dir(200));
pair A = MP("A", (9,0), dir(-80));
pair C = MP("C", (12,0), dir(-20));
pair K = (6,10.392);
pair M = (a*B+(12-a)*K) / 12;
pair N = (b*C+(12-b)*K) / 12;
draw(B--M--N--C--cycle, tpen);
fill(M--A--N--cycle, mediumgrey);
draw(M--A--N--cycle);
pair shift = (-20.13, 0);
pair B1 = MP("B", B+shift, dir(200));
pair A1 = MP("A", K+shift, dir(90));
pair C1 = MP("C", C+shift, dir(-20));
draw(A1--B1--C1--cycle, tpen);[/asy]
Solution: Let $P$ and $Q$ be the points on $\overline{AB}$ and $\overline{AC}$, respectively, where the paper is folded.

Let $x = BP.$  Then $PA = PA' = 12 - x,$ so by the Law of Cosines on triangle $PBA',$
\[x^2 - 9x + 81 = (12 - x)^2.\]Solving, we find $x = \frac{21}{5},$ so $PA = \frac{39}{5}.$

Let $y = CQ.$  Then $QA = QA' = 12 - y,$ so by the Law of Cosines on triangle $QCA',$
\[y^2 - 3y + 9 = (12 - y)^2.\]Solving, we find $y = \frac{45}{7},$ so $QA = \frac{39}{7}.$

Therefore, by the Law of Cosines on triangle $PAQ,$
\[PQ^2 = PA^2 - PA \cdot QA + QA^2 = \boxed{\frac{59319}{1225}}.\][asy]
unitsize(0.25 cm);

pair A, Ap, B, C, P, Q;
real x, y;

x = 21/5;
y = 45/7;

A = 12*dir(60);
Ap = (9,0);
B = (0,0);
C = (12,0);
P = x*dir(60);
Q = C + y*dir(120);

draw(B--C--Q--P--cycle);
draw(P--Ap--Q);
draw(P--A--Q,dashed);

label("$A$", A, N);
label("$A'$", Ap, S);
label("$B$", B, SW);
label("$C$", C, SE);
label("$P$", P, NW);
label("$Q$", Q, NE);
[/asy]